<?php

namespace common\modules\user\models\backend;

use common\widgets\ActiveForm;
use common\widgets\Form;
use common\widgets\Select2;
use Yii;
use yii\helpers\ArrayHelper;

class RuleForm extends Rule
{

    /**
     * @inheritdoc
     */
    public $isNewRecord;

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return parent::rules();
    }

    const SCENARIO_CREATE = 'admin-create';
    const SCENARIO_UPDATE = 'admin-update';

    /**
     * @inheritdoc
     */
    public function scenarios()
    {
        return [
            'admin-create' => array_keys($this->attributeLabels()),
            'admin-update' => array_keys($this->attributeLabels()),
        ];
    }

    /**
     * 返回当前表单的名称
     *
     * @return string
     */
    public function classLabelName()
    {
        return Yii::t('backend/user', 'Rule Form');
    }

    /**
     * 列表定义
     *
     * @param ActiveForm|Form $form
     * @param static          $model ItemForm
     * @param mixed           $extra
     * @return array
     * @throws \yii\web\ServerErrorHttpException
     */
    public function formRows(&$form, $model, $extra)
    {
        return [
            [
                'columns'    => 2,
                'attributes' => [
                    'name' => [
                        'type'    => Form::INPUT_TEXT,
                    ],

                    'class' => [
                        'type'    => Form::INPUT_TEXT,
                    ],
                ],
            ],
        ];
    }
}
